package org.jeecg.modules.acmd.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.acmd.entity.Acmd;
import org.jeecg.modules.acmd.service.IAcmdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

import static org.jeecg.modules.acmd.config.Config.adbRootPath;

/**
 * @Description: 批处理
 * @Author: jeecg-boot
 * @Date: 2022-08-25
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "批处理")
@RestController
@RequestMapping("/acmd/acmd")
public class AcmdController extends JeecgController<Acmd, IAcmdService> {
    @Autowired
    private IAcmdService acmdService;


	 /**
     * 注册手机
     *
     * @param acmd
     * @return
     */
    @AutoLog(value = "批处理-注册手机")
    @ApiOperation(value = "批处理-注册手机", notes = "批处理-注册手机")
    @RequestMapping(value = "/addDevice", method = {RequestMethod.PUT, RequestMethod.POST})
    public Result<?> addDevice(@RequestBody Acmd acmd) {

//          acmdService.doCmd(adbRootPath + "adb kill-server");
//          acmdService.doCmd(adbRootPath + "adb start-server");
//        String s = acmdService.doCmd(adbRootPath + "adb devices");
//        System.out.println(s);
//        if(s.equals("List of devices attached")){
//            System.out.println("初始化成功");
//        }

        return Result.OK("编辑成功!");
    }


//    /**
//     * 分页列表查询
//     *
//     * @param acmd
//     * @param pageNo
//     * @param pageSize
//     * @param req
//     * @return
//     */
//    @AutoLog(value = "批处理-分页列表查询")
//    @ApiOperation(value = "批处理-分页列表查询", notes = "批处理-分页列表查询")
//    @GetMapping(value = "/list")
//    public Result<?> queryPageList(Acmd acmd,
//                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
//                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
//                                   HttpServletRequest req) {
////		QueryWrapper<Acmd> queryWrapper = QueryGenerator.initQueryWrapper(acmd, req.getParameterMap());
////		Page<Acmd> page = new Page<Acmd>(pageNo, pageSize);
////		IPage<Acmd> pageList = acmdService.page(page, queryWrapper);
//
//        return Result.OK(acmdService.doPingCmd());
//    }
//
//    /**
//     * 添加
//     *
//     * @param acmd
//     * @return
//     */
//    @AutoLog(value = "批处理-添加")
//    @ApiOperation(value = "批处理-添加", notes = "批处理-添加")
//    @PostMapping(value = "/add")
//    public Result<?> add(@RequestBody Acmd acmd) {
//        acmdService.save(acmd);
//        return Result.OK("添加成功！");
//    }
//
//    /**
//     * 编辑
//     *
//     * @param acmd
//     * @return
//     */
//    @AutoLog(value = "批处理-编辑")
//    @ApiOperation(value = "批处理-编辑", notes = "批处理-编辑")
//    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
//    public Result<?> edit(@RequestBody Acmd acmd) {
//        acmdService.updateById(acmd);
//        return Result.OK("编辑成功!");
//    }
//
//    /**
//     * 通过id删除
//     *
//     * @param id
//     * @return
//     */
//    @AutoLog(value = "批处理-通过id删除")
//    @ApiOperation(value = "批处理-通过id删除", notes = "批处理-通过id删除")
//    @DeleteMapping(value = "/delete")
//    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
//        acmdService.removeById(id);
//        return Result.OK("删除成功!");
//    }
//
//    /**
//     * 批量删除
//     *
//     * @param ids
//     * @return
//     */
//    @AutoLog(value = "批处理-批量删除")
//    @ApiOperation(value = "批处理-批量删除", notes = "批处理-批量删除")
//    @DeleteMapping(value = "/deleteBatch")
//    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
//        this.acmdService.removeByIds(Arrays.asList(ids.split(",")));
//        return Result.OK("批量删除成功！");
//    }
//
//    /**
//     * 通过id查询
//     *
//     * @param id
//     * @return
//     */
//    @AutoLog(value = "批处理-通过id查询")
//    @ApiOperation(value = "批处理-通过id查询", notes = "批处理-通过id查询")
//    @GetMapping(value = "/queryById")
//    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
//        Acmd acmd = acmdService.getById(id);
//        return Result.OK(acmd);
//    }
//
//    /**
//     * 导出excel
//     *
//     * @param request
//     * @param acmd
//     */
//    @RequestMapping(value = "/exportXls")
//    public ModelAndView exportXls(HttpServletRequest request, Acmd acmd) {
//        return super.exportXls(request, acmd, Acmd.class, "批处理");
//    }
//
//    /**
//     * 通过excel导入数据
//     *
//     * @param request
//     * @param response
//     * @return
//     */
//    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
//    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//        return super.importExcel(request, response, Acmd.class);
//    }
//
//

}
